const log4js = require('log4js')  // 第三方模块

const url = require('url')  // 内置模块

let urlString = 'https://www.baidu.com?id=1#name=mal'

log4js.configure({
  appenders: { cheese: { type: "file", filename: "cheese.log" } },
  categories: { default: { appenders: ["cheese"], level: "error" } }
});
var logger = log4js.getLogger('cheese')
logger.level = 'debug'

// logger.debug(url.parse(urlString));
// logger.debug(url.format({
//   protocol: 'https:',
//   slashes: true,
//   auth: null,
//   host: 'www.baidu.com',
//   port: null,
//   hostname: 'www.baidu.com',
//   hash: '#name=mal',
//   search: '?id=1',
//   query: 'id=1',
//   pathname: '/',
//   path: '/?id=1',
//   href: 'https://www.baidu.com/?id=1#name=mal'
// }));

logger.debug(url.resolve('https://www.baidu.com?name=mal', '/'))